var Loading = function (game) {
    var text;
    this.preload = function () {

        game.scale.scaleMode = Phaser.ScaleManager.SHOW_ALL;

    }
    this.create = function () {
        game.stage.backgroundColor = '#182d3b';


        game.load.image('opening', './asserts/opening.jpg');
        game.load.image('button', './asserts/button.png');


        game.load.image('begin', './asserts/begin.jpg');
        game.load.image('b-0', './asserts/b-0.jpg');
        game.load.image('b_0', './asserts/b_0.jpg');
        game.load.image('b_1', './asserts/b_1.jpg');
        game.load.image('b_2', './asserts/b_2.jpg');


        game.load.image('1', './asserts/1.jpg');
        game.load.image('1_0', './asserts/1_0.jpg');
        game.load.image('1_r', './asserts/1_r.jpg');
        game.load.image('1_w', './asserts/1_w.jpg');
        game.load.image('1r', './asserts/1r.png');
        game.load.image('1w', './asserts/1w.png');
        game.load.image('no_0', './asserts/no_0.png');
        game.load.image('no_1', './asserts/no_1.png');


        game.load.image('2', './asserts/2.jpg');
        game.load.image('2_0', './asserts/2_0.jpg');
        game.load.image('2_r', './asserts/2_r.jpg');
        game.load.image('2_w', './asserts/2_w.jpg');
      game.load.image('1r0', './asserts/1r0.png');
      game.load.image('1w0', './asserts/1w0.png');
        game.load.image('ok_0', './asserts/ok_0.png');
        game.load.image('ok_1', './asserts/ok_1.png');
        game.load.image('no_0', './asserts/no_0.png');
        game.load.image('no_1', './asserts/no_1.png');


        game.load.image('3', './asserts/3.jpg');
        game.load.image('3_r', './asserts/3_r.jpg');
        game.load.image('3_w', './asserts/3_w.jpg');
        game.load.image('3_0', './asserts/3_0.jpg');
        game.load.image('3_03', './asserts/3_03.png');
        game.load.image('3_04', './asserts/3_04.png');
        game.load.image('3_05', './asserts/3_05.png');
        game.load.image('3_06', './asserts/3_06.png');


        game.load.image('4', './asserts/4.jpg');
        game.load.image('4_r', './asserts/4_r.jpg');
        game.load.image('4_w', './asserts/4_w.jpg');
        game.load.image('4_0', './asserts/4_0.jpg');
        game.load.image('4_cof', './asserts/4_cof.png');


        game.load.image('5', './asserts/5.jpg');
        game.load.image('5_0', './asserts/5_0.jpg');
        game.load.image('5_r', './asserts/5_r.jpg');
        game.load.image('5_w', './asserts/5_w.jpg');
        game.load.image('5_00', './asserts/5_0.png');
        game.load.image('5_1', './asserts/5_1.png');
        game.load.image('5_2', './asserts/5_2.png');
        game.load.image('5_3', './asserts/5_3.png');
        game.load.image('5_4', './asserts/5_4.png');
        game.load.image('5_5', './asserts/5_5.png');
        game.load.image('5_6', './asserts/5_6.png');
        game.load.image('5_7', './asserts/5_7.png');


        game.load.image('6', './asserts/6.jpg');
        game.load.image('6_0', './asserts/6_0.jpg');
        game.load.image('6_r', './asserts/6_r.jpg');
        game.load.image('6_w', './asserts/6_w.jpg');
        game.load.image('rect', './asserts/rect.png');


        game.load.image('7', './asserts/7.jpg');
        game.load.image('7_0', './asserts/7_0.jpg');
        game.load.image('7_r', './asserts/7_r.jpg');
        game.load.image('7_w', './asserts/7_w.jpg');
        game.load.spritesheet('d7_0', './asserts/d7_0.jpg', 160, 200, 15);
        game.load.spritesheet('d7_1', './asserts/d7_1.jpg', 160, 200, 15);
        game.load.spritesheet('d7_4', './asserts/d7_4.jpg', 160, 200, 14);
        game.load.spritesheet('d7_3', './asserts/d7_3.jpg', 160, 200, 12);


        game.load.image('8', './asserts/8.jpg');
        game.load.image('8_0', './asserts/8_0.jpg');
        game.load.image('8_r', './asserts/8_r.jpg');
        game.load.image('8_w', './asserts/8_w.jpg');
        game.load.image('d8_0', './asserts/d8_0.png');
        game.load.image('d8_1', './asserts/d8_1.png');
        game.load.image('d8_2', './asserts/d8_2.png');
        game.load.image('d8_3', './asserts/d8_3.png');
        game.load.image('d8_4', './asserts/d8_4.png');
        game.load.image('d8_5', './asserts/d8_5.png');
        game.load.image('Lbox', './asserts/Lbox.png');
        game.load.image('Rbox', './asserts/Rbox.png');


        game.load.image('final', './asserts/final.jpg');



        game.load.image('pix', './asserts/pix.png');
        game.load.image('small', './asserts/small.jpg');


        game.load.start();

        game.load.onLoadStart.add(this.loadStart, this);
        game.load.onFileComplete.add(this.fileComplete, this);
        game.load.onLoadComplete.add(this.loadComplete, this);


        text = game.add.text(game.world.centerX, game.world.centerY, 'Loading ...', {fill: '#ffffff'});
        text.anchor.setTo(0.5, 0.5)
    }


    this.loadStart = function () {
    }

    this.fileComplete = function (progress, cacheKey, success, totalLoaded, totalFiles) {
        var key = cacheKey.toLocaleString();
        imgs[key] = cacheKey;
        text.setText("File Complete: " + progress + "% - " + totalLoaded + " out of " + totalFiles);

    }

    this.loadComplete = function (arg) {
        game.goState('next');
    }


}


